<!--组件-仓位风控-->
<template>

  <div class="bg" v-if="isOk">

    <div class="row acenter" @click="showClick(!isShow)">
      <text class="font28 main-t1">{{T('仓位风控')}}</text>
      <LImage class="arrow"  :src="isShow ? Config.img('xiala_blue_.png') : Config.img('xiala_blue.png')"></LImage>
    </div>

    <div v-if="isShow">
      <div class="bg">
        <!--策略开仓阈值-->
        <LInput class="input" v-model="openThreshold_c" :comment="openThresholdTipe" :title="T('策略开仓阈值')" :tips="T('请输入开仓阈值值')" :unit="'%'"></LInput>  
      </div>
      <div class="mantle" v-if="isEdit" @click="click"></div>
    </div>
  </div>
</template>

<script>

//组件
import LInput from "@/public/view/LInput.vue";
import LSwitc from "@/public/view/LSwitc.vue";

//功能
const globalEvent = weex.requireModule('globalEvent');
import math from "@/_js/math";
import modal from "@/_js/modal";
import Config from "@/_js/config";

import I18N from "@/_i18n/i18n";
var T = I18N.t;

export default {

  components: {
    LInput,
    LSwitc,
  },

  model:{
    prop:"isShow",
    event:"change",
  },
  
  props:{

    isShow:{ //turn显示
      type:Boolean,
      default:false,
    },

    isEdit:{ //turn不可编辑
      type:Boolean,
      default:false,
    },

    //开仓发质
    openThreshold:String, //策略开仓阈值
  },
  
  data() {
    return {
      T:T,
      Config:Config,
      isOk:false, //turn绘制

      openThreshold_c:this.openThreshold ? this.openThreshold : '600', //开仓阈值
      
      openThresholdTipe:T('当担保资产率下降到此值之下时，策略将暂停开仓动作，平仓逻辑不受影响，您可根据风险承受能力自主调节，担保资产率 =（账户权益/(持仓担保资产 + 冻结担保资产)）*100%－交易所调整系数。'),
    };
  },

  mounted(){
    
    if (this.isEdit) {
      this.openThresholdTipe = undefined;
    }
    this.isOk = true;
  },

  methods:{


    //刷新视图
    refresh(){

      this.$emit("change", false);
      this.openThreshold_c = ''; //策略开仓阈值
    },

    //检查
    checkError(){
      if (this.openThreshold_c.length == 0) {
        modal.toast(T("请输入开仓阈值"));
        return true;
      }
      return false;
    },
    
    //获取参数
    getParam(){

      var openThreshold = math.chu(this.openThreshold_c, '100', 4, 2);
      var param = {'openThreshold':openThreshold, //开仓阈值
                  };
      return param;
    },
    
    /********************************** 点击触发*/
    //显隐点击
    showClick(isShow){
      this.$emit("change", isShow);
    },

    //遮挡层，点击遮挡
    click(){
    },
  }
}
</script>


<style src="@/_css/style.css"></style>
<style scoped>
.bg{
  width: 670px;
}
.mantle{
  width: 670px;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.arrow{
  width: 20px;
  height: 20px;
  margin-left: 20px;
  margin-right: 20px;
}

.input {
  margin-top: 40px;
  width: 670px;
}

.switc{
  width: 670px;
}

/*************** 高度*/
.height40{
  height: 40px;
}
</style>
